package com.ruoyi.water.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.water.service.WaterMeterDataService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.water.domain.dto.ApiResponse;
import com.ruoyi.water.domain.dto.WaterMeterDataDTO;

import java.util.List;

/**
 * 表具数据控制器（对外提供API）
 */

@RestController
@RequestMapping("/api/water/meter/data")
public class WaterMeterDataController extends BaseController {

    @Autowired
    private WaterMeterDataService waterMeterDataService;

    @GetMapping("/range")
    public AjaxResult getMeterDataRaw(HttpServletRequest request) {
        String rawQueryParams = request.getQueryString();
        if (rawQueryParams == null || rawQueryParams.trim().isEmpty()) {
            return AjaxResult.error("请求参数不能为空");
        }
        ApiResponse<List<WaterMeterDataDTO>> result = waterMeterDataService.callEnergyPlatformRaw(rawQueryParams);
        return AjaxResult.success(result);
    }
}